package y23.Sep;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test18 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int M = in.nextInt();
        int N = in.nextInt();
        String num = convert(M,N);
        System.out.println(num);
    }
    public static String convert(int M,int N) {
        StringBuilder str = new StringBuilder(8);
        String num;
        char []b = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        while(true){
            str = str.append(b[M%N]);
            if(M / N == 0){
                break;
            }
            M /= N;
        }
        num = str.reverse().toString();
        return num;
    }
}